package com.mars.nacos.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;


/**
 * @author : kyrie
 * @date : 2022/8/23 16:11
 * #desc    : some description
 */
@Api(tags = "订单中心API")
@RestController
@Slf4j
@RequestMapping("/order")
public class OrderAppController {

    @Resource(name = "restTemplate")
    private RestTemplate restTemplate;

    @ApiOperation(value = "获取下单用户昵称", notes = "获取下单用户昵称")
    @GetMapping("/v1/order/info")
    public String getUserName() {
        // 调用用户服务查询用户信息
        String userName = restTemplate.getForObject("http://user-app-api/user/v1/username", String.class);
        log.info("对接用户服务: user-app-api 获取用户昵称，结果为: {}", userName);
        return userName;
    }
}

